/*
 * @Author: KAZU kazu_zhang@163.com
 * @Date: 2023-02-15 21:22:13
 * @LastEditors: KAZU kazu_zhang@163.com
 * @LastEditTime: 2023-02-16 13:11:55
 * @FilePath: \blog-front-frontend\src\components\testimonial\guestbook.jsx
 * @Description: 留言提交嵌套表单
 */
import { Button, Modal } from 'antd';
import { useState } from 'react';
import FormList from './FormList'
const GuestBook = () => {
  const [open, setOpen] = useState(false);
  const [confirmLoading, setConfirmLoading] = useState(false);
  const [modalText, setModalText] = useState('');
  const showModal = () => {
    setOpen(true);
  };
  const handleOk = () => {
    setModalText('正在提交中...');
    setConfirmLoading(true);
    setTimeout(() => {
      setOpen(false);
      setConfirmLoading(false);
      setModalText('');
    }, 2000);
  };
  const handleCancel = () => {
    console.log('Clicked cancel button');
    setOpen(false);
  };
  return (
    <>
      <Button type="primary" onClick={showModal}>
        点我试试
      </Button>
      <Modal
        title="你想对我说些什么？😋"
        open={open}
        onOk={handleOk}
        confirmLoading={confirmLoading}
        onCancel={handleCancel}
        footer={
          [] // 设置footer为空，去掉 取消 确定默认按钮
        }
      >
        <FormList />
        <p>{modalText}</p>
      </Modal>
    </>
  )
}

export default GuestBook